package com.unchartedskies.controller.command
{
	import com.gamesmile.framework.util.Log;
	import com.unchartedskies.controller.event.AccueilClickEvent;
	import com.unchartedskies.controller.event.LoginClickEvent;
	import com.unchartedskies.model.State;
	import com.unchartedskies.model.service.PlayerIOService;
	import com.unchartedskies.model.value.StateConstant;
	import com.unchartedskies.view.Accueil;
	import com.unchartedskies.view.Login;
	
	import org.robotlegs.mvcs.Command;
	
	import playerio.Client;
	import playerio.PlayerIOError;
	
	public class LoginCommand extends Command
	{
		[Inject]
		public var loginClickEvent:LoginClickEvent;
		
		[Inject]
		public var state:State;
		
		[Inject]
		public var playerIOService:PlayerIOService;
		
		override public function execute():void
		{
			Log.debug(this,"Execute LoginClickCommand");
			Log.debug(this,"Target name  "+loginClickEvent.targetName);
			
			switch(loginClickEvent.targetName)
			{
				case Login.BT_GUEST:
				{
					handleGuestConnexion();
				break;
				}
				default:
				{
				break;
				}
			}
		}
	                            	            
		private function handleGuestConnexion():void
		{
			playerIOService.connect(contextView.stage);
		}
	}
}